<%@ page language="java" contentType="text/html; charset=utf-8"
	import="java.util.*,kk.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<title>新闻发布系统管理后台</title>
<link href="css/admin.css" rel="stylesheet" type="text/css" />
<div id="header">
  <div id="welcome">欢迎使用新闻管理系统！</div>
  <div id="nav">
    <div id="logo"><img src="images/logo.jpg" alt="新闻中国" /></div>
    <div id="a_b01"><img src="images/a_b01.gif" alt="" /></div>
  </div>
</div>
<div id="admin_bar">
  <div id="status">管理员： admin 登录  &#160;&#160;&#160;&#160; <a href="../util/do_logout.jsp">login out</a></div>
  <div id="channel"> </div>
</div>
<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
 <script>function test(){
            var form = new FormData(document.getElementById("tf"));
//             var req = new XMLHttpRequest();
//             req.open("post", "${pageContext.request.contextPath}/public/testupload", false);
//             req.send(form);
            $.ajax({
                //url:"${pageContext.request.contextPath}/public/testupload",
                url:"Update1",
                type:"post",
                data:form,		
//		注：如果没有文件，只是简单的表单数据则可以使用 $('#formid').serialize();
//		data:$('#formid').serialize();
                processData:false,	//必须有
                contentType:false,	//必须有	
                success:function(data){
                    window.clearInterval(timer);
                    console.log("over..");
                },
                error:function(e){
                    alert("错误！！");
                    window.clearInterval(timer);
                }
            });        
            get();//此处为上传文件的进度条
        }
</script>
</head>
<body>
<%
Long nid=Long.parseLong(request.getParameter("nid"));
Long ntid=Long.parseLong(request.getParameter("ntid"));
String ntitle=request.getParameter("ntitle");
 %>
	
	
	<script type="text/javascript">
	function check(){
		var ntitle = document.getElementById("ntitle");
		var nauthor = document.getElementById("nauthor");
		var nsummary = document.getElementById("nsummary");
		var ncontent = document.getElementById("ncontent");
		
		if(ntitle.value == ""){
			alert("标题不能为空！！");
			ntitle.focus();
			return false;
		}else if(nauthor.value == ""){
			alert("作者不能为空！！");
			nauthor.focus();
			return false;
		}else if(nsummary.value == ""){
			alert("摘要不能为空！！");
			nsummary.focus();n
			return false;
		}else if(ncontent.value == ""){
			alert("内容不能为空！！");
			ncontent.focus();
			return false;
		}		
		return true;
	}
</script>

<div id="main">
  <div id="opt_list">
  <ul>
    <li><a href="news_control.jsp?opr=findTopics">添加新闻</a></li>
    <li><a href="modifyShow.jsp">编辑新闻</a></li>
    <li><a href="topic_add.jsp">添加主题</a></li>
    <li><a href="../TopicServlet?opr=list">编辑主题</a></li>
  </ul>
</div>

  <div id="opt_area">
    <h1 id="opt_type"> 编辑新闻： </h1>
    <form action="<%--news_control.jsp--%><%--?opr=updateNews--%>" id="tf" <%--method="post" enctype="multipart/form-data"--%>onsubmit="return check()">
      <p>
        <label> 主题 </label>
        <select name="ntid">
        <%
        	 NewsDao n=new NewsDao();
             TopicDao n4=new TopicDao();
             List<Topic> l1=n4.findAll();
             int count=1;
             for(Topic n3:l1){%>
	         <option value='<%=n3.getTid()%>'<%if(n3.getTid()==ntid){%>selected='selected'<%}%> id='<%=count%>'><%count++;%><%--n3.getTid()--%><%=n3.getTname()%></option>	
	       <%}%>    	
        </select>
        <input type="hidden" name="nid" value="<%=nid%>" />
      </p>
      <p>
        <label> 标题 </label>
        <input name="ntitle" id="ntitle" type="text" class="opt_input" value="<%=n.get(nid).getNtitle()%>"星跳水立方"决战临近 陈楚生被华谊要求进前三"/>
      </p>
      <p>
        <label> 作者 </label>
        <input name="nauthor" id="nauthor" type="text" class="opt_input" value="<%=n.get(nid).getNauthor()%>"/>
      </p>
      <p>
        <label> 摘要 </label>
        <textarea name="nsummary" id="nsummary" cols="40" rows="3"> <%
        	String s3=n.get(nid).getNsummary();
        	out.print(s3);
        %></textarea>
      </p>
      <p>
        <label> 内容 </label>
        <textarea name="ncontent" id="ncontent" cols="70" rows="10">
        <%
        	String s4=n.get(nid).getNcontent();
        	out.print(s4);
        %>
</textarea>
      </p>
      <p>
        <label> 上传图片 </label>
        <span><img src="<%=n.get(nid).getNpicpath()%>"/></span>
        <input name="file" id="file" type="file" class="opt_input" />
      </p>
      <%--<input type="submit" value="提交" class="opt_sub" />--%>
       <input type="button" value="提" onclick="test();"/> 
      <input type="reset" value="重置" class="opt_sub" />
    </form>
    <h1 id="opt_type">
		修改新闻评论：
	</h1>
	<div>
      <table width="80%" align="left">
     
      	<td colspan="6">  <% 
      	
      CommentDao c=new CommentDao();
      List<Comment> l=c.findComments(nid);
      for(Comment cm:l){%>
      	<div><%=cm.getCcontent()%><%=cm.getCauthor()%><%=cm.getCip()%><%=cm.getCdate()%></div>
      	<a onclick="return check1('5555')" href="Shanchu?cid=<%=cm.getCid()%>&fenlei=pinglun">删除</a>	
      <% }
      %> </td>
         <tr>
           <td colspan="6"><hr />
           </td>
         </tr>
      </table>
     </div> 
  </div>
</div>

<div id="site_link"> <a href="#">关于我们</a><span>|</span> <a href="#">Aboue Us</a><span>|</span> <a href="#">联系我们</a><span>|</span> <a href="#">广告服务</a><span>|</span> <a href="#">供稿服务</a><span>|</span> <a href="#">法律声明</a><span>|</span> <a href="#">招聘信息</a><span>|</span> <a href="#">网站地图</a><span>|</span> <a href="#">留言反馈</a> </div>
<div id="footer">
  <p class="">24小时客户服务热线：010-68988888  &#160;&#160;&#160;&#160; <a href="#">常见问题解答</a> &#160;&#160;&#160;&#160;  新闻热线：010-627488888<br />
    文明办网文明上网举报电话：010-627488888  &#160;&#160;&#160;&#160;  举报邮箱：<a href="#">jubao@jb-aptech.com.cn</a></p>
  <p class="copyright">Copyright &copy; 1999-2009 News China gov, All Right Reserver<br />
    新闻中国   版权所有</p>
</div>
</body>
</html>